package org.example.controller;

import jakarta.annotation.Resource;
import org.example.service.BookService;
import org.example.util.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    private BookService bookService;
    @GetMapping("/fresh")
    public JsonResult findFreshBook() {
        return bookService.findFreshBook();
    }
    @GetMapping("/lower")
    public JsonResult findLowerBook() {
        return bookService.findlowerBook();
    }
    @GetMapping("/fresh_more/{page}")
    public JsonResult findFreshMoreBook(@PathVariable("page") int page) {
        return bookService.findFreshBookMore(page);
    }
    @GetMapping("/lower_more/{page}")
    public JsonResult findLowerMoreBook(@PathVariable("page") int page) {
        return bookService.findlowerBookMore(page);
    }
    @GetMapping("/search_book/{name}/{page}")
    public JsonResult searchBook(@PathVariable("name") String name, @PathVariable("page") int page) {
        return bookService.findSearchByBookName(name,page);
    }
    @GetMapping("/category/{id}/{page}")
    public JsonResult findCategory(@PathVariable("id") String categoryId, @PathVariable("page") int page) {
        return bookService.findCategoryBook(categoryId,page);
    }

}
